<?php session_start();?>
<?php
	require_once ("./config.inc.php");
	require_once ("./include/mysql.inc.php");
	require_once ("./include/article.inc.php");
	
	$articleDao = new Article();
	$pageIndex = mysql_escape_string($_GET['page']);
	$typeId = mysql_escape_string($_GET['id']);
	$typeName = '';
	if (empty($typeId)) {
		$typeId = '';
		$typeName = '全部文章列表';
	}
	$articleList = $articleDao->query($typeId, $pageIndex, ARTICLE_PAGE_SIZE);
	$articleNum = $articleDao->count($typeId);
	
	if (count($articleList)== 0) {
		$typeName = '该类型的文章列表为空';
	}
	else {
		$typeName = $articleList[0]['name'] . '-文章列表';
	}
	
	require_once('./include/page.class.php');
	$pageSize = ARTICLE_PAGE_SIZE;
	$total = $articleNum;
	pageft($articleNum, ARTICLE_PAGE_SIZE, 1, 1, 0, 5);
	//第一个0显示数字  第二个1显示概况 第三个显示下拉 第四个显示数字数量
	//pageft($total,$pageSize,1,1,0,5);
?>
<!DOCTYPE HTML>
<html>
<head>
	<link rel="shortcut icon" href="res/icons/favicon.ico">
	<title><?php echo $typeName; ?></title>
	<meta name="description" content="wzwahl36 王小为的技术博客  Xewee Wang's HomePage..." />
	<meta name="keywords" content="wzwahl36, 王小为, Xewee Wang" />
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>

<body>
  <div id="main">
  <?php 
  	require_once ("./inc.header.php");
  ?>
    <div id="site_content">
      <?php
      	require_once ("./inc.right.php");
      ?>    
      <div id="content">
      	<h1><a href="list.php?id=<?php echo $typeId;?>&page=<?php echo $pageIndex + 1?>">Blog List</a></h1>
      	<ul>
      		<?php foreach ($articleList as $article) {?>
      		<li>
      			<?php echo ($article['top'] == 1 ? '<red>[HOT]</red>  ' : '');?>
      			<a href="blog.php?id=<?php echo $article['id'];?>"><?php echo $article['title'];?></a>&nbsp;&nbsp;
      			<a class="tag" href="list.php?id=<?php echo $article['typeId'];?>&page=1">&nbsp;<?php echo $article['name'];?>&nbsp;</a>
      			<div style="float:right; margin-right:10px;">
      				<a><?php echo $article['adminId'];?></a> at <?php echo $article['time'];?>
      			</div>
      		</li>
      		<?php }?>
      	</ul>
      	<div class="msdn"><?php echo $pagenav;?></div>
      </div>
    </div>
    <?php
    	require_once ("./inc.footer.php");
    ?>
  </div>
</body>
</html>